### INTRODUCTION

This folder contains the replication materials for the research note
"Conventional and Unconventional Participation in Latin America: A Hierarchical Latent Class Approach",
by Alvarez, Katz, Levin and Nunez, to appear in Political Science Research and Methods. 

Given the complexity of the model, the Markov chain Monte Carlo (MCMC) algorithm was coded in C++ and called from R through Rcpp (Eddelbuettel, 2013), and executed via the University of Exeter High Performance 
Computing (HPC) cluster - see Section A.2 in the accompanying Online Appendix. While all the models can be estimated using a laptop or desktop computer, the execution time is considerably (around 5 times) shorter using a HPC cluster. 


For the code to work properly, you have to install an SSH Client (such as Putty or smilar) to connect to an HPC cluster, as well as the following R packages: "Rcpp", "RcppArmadillo", "RcppGSL", �RcppZiggurat�, "coda", "Hmisc", "mlogit", "MASS", "ggplot2", "gridExtra", "gtable", and "grid". 
When using a HPC cluster, you should load the R module (we used version 3.6.0).


### DESCRIPTION OF THE FILES

In the estimation of each of the models reported in the research note and accompanying Online Appendix, we use:
1) A batch (shell) script (extension: ".sh"; e.g. "Model.sh") that submits the relevant R script to the HPC cluster. 
   Exeter's HPC cluster uses Moab to manage the cluster workload.
2) An R script (extension: ".R"; e.g., "Model.R") that loads the relevant dataset, prepares the data for estimation, 
   and calls Rcpp to run the MCMC algorithm.
3) A C++ code (extension: ".cpp�) that contains the relevant MCMC algorithm - which depends on the functional form assumed for the cumulative density function F() in equation 2 of the research note, on whether the probabilities of type assignment are modelled as a function of covariates or not, on whether metric or scalarinvariance is assumed or not, on the number of participatory types assumed, and on whether the participatory dimensions are assumed to be discrete or continuous (see details below).
   

Once the models are estimated, we post-process all the results in R (see the description of "Processing.R" below).

Hence, these replication materials include the following files:


1) Files required to estimate the models used to produce the empirical findings in the research note and the Online Appendix:

   1.1) "MainModel.sh", "MainModel.R", "LATAMprobit.cpp": 
	the batch file, R script and MCMC algorithm (coded in .cpp) 
	to estimate the main specification presented in the research note 
	and in Section A.3.1 of the Online Appendix. 
	This main specification assumes that F() is the cdf of a standard normal 
	distribution.

   1.2) "MetricinvarianceModel.sh", "MetricinvarianceModel.R", "LATAMminvariance.cpp": 
	 the batch file, R script and MCMC algorithm (coded in .cpp) to estimate 
	the model assuming metric invariance, presented in Table 3 (column 2) of 
	the research note.

   1.3) "ScalarinvarianceModel.sh", "ScalarinvarianceModel.R", "LATAMsinvariance.cpp": 
	the batch file, R script and MCMC algorithm (coded in .cpp) to estimate 
	the model assuming scalar invariance, presented in Table 3 (column 3) of 
	the research note.

   1.4) "SingleclassModel.sh", "SingleclassModel.R", "LATAMsingleclass.cpp": 
	the batch file, R script and MCMC algorithm (coded in .cpp) to estimate 
	the model assuming a single participatory type, presented in Table 3
	 (column 4) of the research note.

   1.5) "MacroModel.sh" and "MacroModel.R": the batch file and R script to 
	estimate the specification including only contextual variables reported 
	in Figure A.6 (Section A.3.1) of the Online Appendix. 
	The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp".

   1.6) "MicroModel.sh", "MicroModel.R", "LATAMmicrovars.cpp": 
	the batch file, R script and MCMC algorithm (coded in .cpp) to estimate 
	a specification that includes only individual-level covariates as 
	determinants of the probabilities of the probabilities of type assignment. 
	The results from this model are reported in Table A.6 (Section A.3.1) 
	of the Online Appendix.  

   1.7) "NocovarsModel.sh", "NocovarsModel.R", "LATAMnocovars.cpp": 
	the batch file and R script and MCMC algorithm (coded in .cpp) to estimate
	 a specification that does not include (individual or macro-level) 
	 covariates as determinants of the probabilities of type assignment. 
	The results from this model are reported in Table A.6 (Section A.3.1) of 
	the Online Appendix.  

   1.8) "DirichletModel.sh", "DirichletModel.R", "LATAMdirichlet.cpp": 
	the batch file and R script and MCMC algorithm (coded in .cpp) to estimate
	the model with uniform Dirichlet priors for the participatory dimensions. 
        The results from this model are reported in Figure A.7 (Section A.3.1) of 
	the Online Appendix.  

   1.9) "LogitModel.sh", "LogitModel.R", "LATAMlogit.cpp": 
	the batch file, R script and MCMC algorithm (coded in .cpp) to estimate 
	the model specifying F() - equation 2 of the research note - as de cdf of
	 a standard logistic distribution. 
	The results from this model are presented in Section A.3.2 of the 
	Online Appendix.

   1.10) "IncomeproxyModel.sh" and "IncomeproxyModel.R": the batch file and R 
	script to estimate the model using "Income (proxy)" instead of "Relative 
	Income (proxy)" as a measure of income. 
	The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp".
	The results of this specification are reported in Figure A.15 
	(Section A.3.3) of the Online Appendix. 

   1.11) "IncomeaboveaverageModel.sh" and "IncomeaboveaverageModel.R": the batch
	 file and R script to estimate the model using "Above-average (monetary)
	 Income" instead of "Relative Income (proxy)" as a measure of income. 
         The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp".
	 The results of this specification are reported in Figure A.16 
	 (Section A.3.3) of the Online Appendix. 

   1.12) "IncomequartilesModel.sh" and "IncomequartilesModel.R": the batch file
	 and R script to estimate the model using indicators for the second, 
	 third and fourth income quartiles instead of "Relative Income (proxy)"
         as a predictor. 
	 The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp".
	 The results of this specification are reported in Figure A.17
	 (Section A.3.3) of the Online Appendix. 

   1.13) "LAPOPIncomeModel.sh" and "LAPOPIncomeModel.R": the batch file and 
	 R script to estimate the model using "Continuous LAPOP Income Variable" 
	 instead of "Relative Income (proxy)" as a predictor. 
	 The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp". 
	 The results of this specification are reported in Figure A.18 
	 (Section A.3.3) of the Online Appendix.

   1.14) "DeprivationModel.sh" and "DeprivationModel.R": the batch file and 
	  R script to estimate the model using "Perceived Relative Deprivation" 
	  instead of "Relative Income (proxy)" as a predictor. 
	  The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp". 
	  The results of this specification are reported in Figure A.19 
	  (Section A.3.3) of the Online Appendix.

   1.15) "GovsupportModel.sh" and "GovsupportModel.R": the batch file and R script
	 to estimate the model using "Government Support" instead of "Ideological
	 Distance to Incumbent" as a measure of respondents' ideological 
	 preferences. 
	 The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp". 
	 The results of this specification are reported in Section A.3.4 
	 (Table A.9 and Figures A.20 - A.25) of the Online Appendix.

   1.16) "VoteintentionModel.sh" and "VoteintentionModel.R": the batch file and R
	 script to estimate the model using "Prospective Vote for Incumbent" 
	 instead of "Ideological Distance to Incumbent" as a measure of 
	 respondents' ideological preferences. 
	 The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp". 
	 The results of this specification are reported in Section A.3.4 
	 (Figures A.26 - A.28) of the Online Appendix.

   1.17) "PartisanshipModel.sh" and "PartisanshipModel.R": the batch file and R 
	  script to estimate the model using "Close to Incumbent Party" instead of
	  "Ideological Distance to Incumbent" as a measure of respondents' 
	  ideological preferences. 
	  The MCMC algorithm used to fit this model is included in "LATAMprobit.cpp". 
	  The results of this specification are reported in Section A.3.4 
	  (Figures A.26 - A.28) of the Online Appendix.

   1.18) The batch files "Wave2010.sh", "Wave2012.sh", "Wave2014.sh", 
	 "Wave2016.sh", "Wave2018.sh", and the R scripts "Wave2010.R", 
	 "Wave2012.R", "Wave2014.R", "Wave2016.R", and "Wave2018.R", are used to
	 fit our baseline model to data from all the AmericasBarometer surveys 
	 fielded between 2010 and 2018, as reported in Section A.3.5 of the 
	 Online Appendix. 
	 The MCMC algorithm used to fit these models is included in "LATAMprobit.cpp". 

   1.19) "ContinuousModel.sh", "ContinuousModel.R", "LATAMcontinuous.cpp": 
	 the batch file, R script and MCMC algorithm (coded in .cpp) to estimate 
	 the factor-analytic model specifying the (conventional and unconventional) 
	 dimensions of political participation as continuous variables. 
	 The results from this model are presented in Section A.3.6 of the Online 
	 Appendix.


2) "Processing.sh" and "Processing.R": the batch file and main R script used to 
    post-process the estimates from all the models and to produce the posterior 
    summaries and descriptive statistics reported in the tables and figures 
    included in the research note and the Online Appendix. 


3) The data sets employed in the analyses: 

   3.1) "dataset_2012": data set used to produce the estimation results reported 
	in the research note as well as in Sections A.3.1 - A.3.3 and A.3.6 of 
	the Online Appendix.

   3.2) "dataset_2012_wpartysupport": data set including alternative measures of
	 individuals' ideological preferences used to produce the estimation results 
	 reported in Section A.3.4 of the Online Appendix.

   3.3) "dataset_2010to2018": data set including variables from all the 
	 AmericasBarometer surveys fielded between 2010 and 2018, used to produce
	 the estimation results reported in Section A.3.5 of the Online Appendix.

   Each of these datasets is called by the relevant .R scripts used for 
   estimation and processing.


AUTHOR'S CONTACT INFORMATION:			

Gabriel Katz, University of Exeter and Universidad Catolica del Uruguay. 
Amory Building, Rennes Drive, Exeter, EX4 4QJ, UK
email: G.Katz@exeter.ac.uk.







